package com.street.controller.admin;

import com.street.dto.DishDTO;
import com.street.entity.Dish;
import com.street.result.Result;
import com.street.service.DishService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController("adminDishController")
@RequestMapping("/admin/dish")
public class DishController {
    @Autowired
    DishService dishService;

    @GetMapping("/list")
    public Result<List<Dish>> list(Integer shopId){
        List<Dish> dishList = dishService.listDish(shopId);
        return Result.success(dishList);
    }

    @PostMapping("/add")
    public Result addDish(@RequestBody DishDTO dto){
        dishService.insert(dto);
        return Result.success();
    }

    @PutMapping("/modify")
    public Result update(@RequestBody DishDTO dto){

        dishService.update(dto);
        return Result.success();
    }
    @DeleteMapping("/{id}")
    public Result deleteById(@PathVariable Integer id){
        dishService.deleteById(id);
        return Result.success();
    }
    @PostMapping("/status/{status}")
    public Result EnableOrUnableStatus(@PathVariable Integer status, Integer dishId){
        dishService.EnableOrUnableStatus(status,dishId);
        return Result.success();
    }
}
